<?php 
class Default_Model_Customer extends Zend_Db_Table_Abstract
{
	private $db = null;
	protected $_name = 'customer'; 
  	protected $_primary = 'customer_id'; 
  	const SPECALEP = 17;
	public function init()
	{
		$this->db = Zend_Registry::get('DB');
	}
	public function listCustomer($data = null)
	{
		$select = $this->select("cusomter");		
		return $select;
	}
	public function getTableName()
	{
		return $this->_name;
	}
	public function getIdAndName()
	{
		$select = $this->db->select()
					   ->from(array('c'=>'customer'),'customer_id')						  
					   ->columns("customer_fname")
					   ->columns("customer_lname");
		$data = $this->db->query($select)->fetchAll();
		return $data;
	} 
	public function addCustomer($data)
	{	
		$data['customer_birthday'] = date('Y-m-d',strtotime($data['customer_birthday']));
		return $this->insert($data);
	}
	public function getCustomer($id)
	{
		$result = $this->find($id)->toArray();
		return $result[0];
	}
	public function delCustomer($id)
	{
		$where = $this->db->quoteInto('customer_id = ?', $id);
		return $this->delete($where);
	}
	public function updateCustomer($id,$data)
	{
		$data['customer_birthday'] = date('Y-m-d',strtotime($data['customer_birthday']));
		$where = $this->db->quoteInto('customer_id = ?', $id);
		return $this->update($data,$where);
	}
}